package com.chensheng.dto;

import lombok.Data;

/**
 * @Author:ChenSheng
 * @Description: code 0 成功； code 1 失败
 * @Date: Created in 下午 22:41 2018/5/13 0013
 */
@Data
public class ResultDTO<T> {
    private Integer code;

    private String msg;

    private T data;

    public static <T> ResultDTO<T> success(T data){
        ResultDTO<T> res = new ResultDTO<T>(0, "成功", data);
        return res;
    }

    public static <T> ResultDTO<T> error(T data){
        ResultDTO<T> res = new ResultDTO<>(1, "失败", data);
        return res;
    }

    private ResultDTO(Integer code, String msg, T data){
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public ResultDTO(){}
}
